
import { useDispatch, useSelector, ArticleModelState } from 'umi';
import { useEffect } from 'react';
import { IArticleItem } from '@/types';

import { formatDate } from '@/utils';
//引入多个样式
import style from "./index.less";


export default function recommendread() {
    const dispatch = useDispatch();
    const { articleComment,  } = useSelector((state: { article: ArticleModelState }) => ({ ...state.article }));
    // console.log(articleComment);
    // 发起请求
    useEffect(() => {
        dispatch({
            type: 'article/getArticleRecommend'
        })
        dispatch({
            type: 'article/getArticleState'
        })
    }, [])
    return (
        <div className={style.flet}>
            <div className={style.flet_title}>
                <span>推荐阅读</span>
            </div>
            <ul className={style.sidebarul_1}>
                {articleComment.map((item: IArticleItem) => {
                    return <li key={item.id} >
                        <a href={`/article/${item.id}`}>{item.title}</a>
                        &emsp;<time className="formatDate">{formatDate(item.createAt) + '前'}</time>
                    </li>


                })}
            </ul>
        </div>
    );
}
